package com.cz.basetool.ui_work.util.et_bind;

import android.util.Pair;

import com.cz.basetool.R;
import com.cz.basetool.ui_work.util.txt.CZ_TextUtil;
import com.cz.basetool.ui_work.util.txt.RegularUtil;
import com.cz.basetool.ui_work.util.et_bind.base.BaseEditTextValidator;

/**
 * Created by 陈章 on 2017/4/12 0012.
 * func:
 * 邮箱校验器
 */
public class EmailValidator extends BaseEditTextValidator {
    public EmailValidator() {
    }

    public EmailValidator(OnValidatorResultObserver validatorResultObserver) {
        super(validatorResultObserver);
    }

    @Override
    public Pair validate(String email) {
        //邮箱为空
        if(CZ_TextUtil.is_null_or_empty(email)){
            return getRightPair();
        }

        //邮箱不合法
        if(!RegularUtil.isEmail(email)){
            return getErrorPair(mContext.getString(R.string.warn_input_email_illegal));
        }
        return getRightPair();
    }
}
